import re

pattern = ".*2.*0.*2.*4"
result = 0
for i in range(12345678, 98765433):
    if not re.search(pattern, str(i)):
        result += 1
print(result)
